android.ndk.hardware_buffer

@defgroup AHardwareBuffer Native Hardware Buffer

AHardwareBuffer objects represent chunks of memory that can be accessed by various hardware components in the system. It can be easily converted to the Java counterpart android.hardware.HardwareBuffer and passed between processes using Binder. All operations involving AHardwareBuffer and HardwareBuffer are zero-copy, i.e., passing AHardwareBuffer to another process creates a shared view of the same region of memory.

AHardwareBuffers can be bound to EGL/OpenGL and Vulkan primitives. For EGL, use the extension function eglGetNativeClientBufferANDROID to obtain an EGLClientBuffer and pass it directly to eglCreateImageKHR. Refer to the EGL extensions EGL_ANDROID_get_native_client_buffer and EGL_ANDROID_image_native_buffer for more information. In Vulkan, the contents of the AHardwareBuffer can be accessed as external memory. See the VK_ANDROID_external_memory_android_hardware_buffer extension for details.

@{

Members

Enums

AHardwareBuffer_Format
enum AHardwareBuffer_Format

Buffer pixel formats.

AHardwareBuffer_UsageFlags
enum AHardwareBuffer_UsageFlags

Buffer usage flags, specifying how the buffer will be accessed.

Functions

AHardwareBuffer_acquire
void AHardwareBuffer_acquire(AHardwareBuffer* buffer)

Acquire a reference on the given AHardwareBuffer object.

AHardwareBuffer_allocate
int AHardwareBuffer_allocate(const(AHardwareBuffer_Desc)* desc, AHardwareBuffer** outBuffer)

Allocates a buffer that matches the passed AHardwareBuffer_Desc.

AHardwareBuffer_describe
void AHardwareBuffer_describe(const(AHardwareBuffer)* buffer, AHardwareBuffer_Desc* outDesc)

Return a description of the AHardwareBuffer in the passed AHardwareBuffer_Desc struct.

AHardwareBuffer_isSupported
int AHardwareBuffer_isSupported(const(AHardwareBuffer_Desc)* desc)

Test whether the given format and usage flag combination is allocatable.

AHardwareBuffer_lock
int AHardwareBuffer_lock(AHardwareBuffer* buffer, ulong usage, int fence, const(ARect)* rect, void** outVirtualAddress)

Lock the AHardwareBuffer for direct CPU access.

AHardwareBuffer_lockAndGetInfo
int AHardwareBuffer_lockAndGetInfo(AHardwareBuffer* buffer, ulong usage, int fence, const(ARect)* rect, void** outVirtualAddress, int* outBytesPerPixel, int* outBytesPerStride)

Lock an AHardwareBuffer for direct CPU access.

AHardwareBuffer_lockPlanes
int AHardwareBuffer_lockPlanes(AHardwareBuffer* buffer, ulong usage, int fence, const(ARect)* rect, AHardwareBuffer_Planes* outPlanes)

Lock a potentially multi-planar AHardwareBuffer for direct CPU access.

AHardwareBuffer_recvHandleFromUnixSocket
int AHardwareBuffer_recvHandleFromUnixSocket(int socketFd, AHardwareBuffer** outBuffer)

Receive an AHardwareBuffer from an AF_UNIX socket.

AHardwareBuffer_release
void AHardwareBuffer_release(AHardwareBuffer* buffer)

Remove a reference that was previously acquired with AHardwareBuffer_acquire() or AHardwareBuffer_allocate().

AHardwareBuffer_sendHandleToUnixSocket
int AHardwareBuffer_sendHandleToUnixSocket(const(AHardwareBuffer)* buffer, int socketFd)

Send the AHardwareBuffer to an AF_UNIX socket.

AHardwareBuffer_unlock
int AHardwareBuffer_unlock(AHardwareBuffer* buffer, int* fence)

Unlock the AHardwareBuffer from direct CPU access.

Structs

AHardwareBuffer
struct AHardwareBuffer

Opaque handle for a native hardware buffer.

AHardwareBuffer_Desc
struct AHardwareBuffer_Desc

Buffer description. Used for allocating new buffers and querying parameters of existing ones.

AHardwareBuffer_Plane
struct AHardwareBuffer_Plane

Holds data for a single image plane.

AHardwareBuffer_Planes
struct AHardwareBuffer_Planes

Holds all image planes that contain the pixel data.

Meta